package com.xudow.app.newui.fragment;


import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.activeshare.edu.ucenter.models.course.CourseSetUpItem;
import com.xudow.app.R;
import com.xudow.app.newui.base.BaseUiFragment;

import java.util.List;

import butterknife.BindView;

/**
 * 课程评价项目Fragment
 * A simple {@link } subclass.
 */
public class SupervisionFragemtn extends BaseUiFragment {
    private int type;

    List<CourseSetUpItem> data;
    int[] ivs;
    int start=0,end=0;
    public SupervisionFragemtn(){

    }
    public void setType(int t){
        this.type=t;

        switch (type){
            case 0:
                start=0;
                end=3;
                ivs=new int[]{R.id.iv_1,R.id.iv_2,R.id.iv_3,R.id.iv_4};
                break;
            case 1:
                start=4;
                end=12;
                ivs=new int[]{R.id.iv_5,R.id.iv_6,R.id.iv_7,R.id.iv_8,
                        R.id.iv_9,R.id.iv_10,R.id.iv_11,R.id.iv_12,R.id.iv_13};
                break;
            case 2:
                start=13;
                end=16;
                ivs=new int[]{R.id.iv_14,R.id.iv_15,R.id.iv_16,R.id.iv_17};
                break;
            case 3:
                start=17;
                end=21;
                ivs=new int[]{R.id.iv_18,R.id.iv_19,R.id.iv_20,R.id.iv_21,R.id.iv_22};
                break;
        }
        Log.e("gettype","type="+type+"ivs.size="+ivs.length);
    }
    public int getType() {
        return type;
    }
    View v;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        switch (type){
            case 0:
                v=View.inflate(getContext(),R.layout.fragment_supervision_fragemtn, null);

                break;
            case 1:
                v=View.inflate(getContext(),R.layout.fragment_supervision_fragemtn1, null);

                break;
            case 2:
                v=View.inflate(getContext(),R.layout.fragment_supervision_fragemtn2, null);

                break;
            case 3:
                v=View.inflate(getContext(),R.layout.fragment_supervision_fragemtn3, null);

                break;
        }


        return v;
    }


    public void updataInfo(List<CourseSetUpItem> setups){
        if (null==data) {
            this.data = setups;
            Log.e("getdata", "setups" + setups.size());

        }
    }

    @Override
    public void onResume() {
        Log.e("resume","type"+type+"---ivs.size="+ivs.length);
        super.onResume();
        resumInfor();
    }

    private void resumInfor() {
        if (null!=data&&data.size()>0){

            for (int i=start,j=0;i<=end;i++,j++){
                CourseSetUpItem setup=data.get(i);
                    if (null!=setup.getSetup()&&null!=setup.getSetup().getStatus()) {
                        if (setup.getSetup().getStatus() == 1) {
                            if (null==ivs)
                                Log.e("ivs[]", type+"-------"+(null==ivs));
                            else
                                ((ImageView) v.findViewById(ivs[j])).setImageResource(R.mipmap.supervision_good_ico);
                        }
                    }
            }
        }
    }



    @Override
    protected void initData() {


    }

    @Override
    protected void initListener() {

    }


}
